# Tuxlocator gprs modem deamon
# (c) 2007 by Rein Velt / http://geo.velt.org
# Published under the terms and conditions
# of the General Public License (GPL)
while true
do
  modemConnected="`dmesg | grep ttyATM0 | wc -l`"
  case $modemConnected in
	0) 	#modem is not connected
		modemActive=0
		;;
	1)	#modem is connected
		modemActive="`/sbin/ifconfig ppp0 | wc -l`"
		case $modemActive in
		0)	#ppp not running
			/mnt/flash/etc/ppp-start &
			sleep 30
			;;
		esac
		;;
  esac
  echo $modemConnected > /var/gprs_available
  echo $modemActive > /var/gprs_active
  sleep 30
done
exit 0 
